import 'package:car_map/mode/spuare_type_mode.dart';
import 'package:car_map/utils/image_utils.dart';
import 'package:car_map/widget/spuare_type_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Widget4SSliverAdapter extends StatefulWidget {

  @override
  _widget4SSliverAdapterState createState() =>_widget4SSliverAdapterState();
}

class _widget4SSliverAdapterState extends State<Widget4SSliverAdapter>{

  List<SpuareTypeModel> spuareType;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getSpuareList();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 10.0),
      width: ScreenUtil().setWidth(750),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[
          itemList( spuareType[0],),
          itemList( spuareType[1],),
          itemList( spuareType[2],),
          itemList( spuareType[3],),
        ],
      ) ,
    );
  }


  List<SpuareTypeModel> getSpuareList(){
    spuareType=new List();
    spuareType.add(new SpuareTypeModel(title: '定制车',urlPath: 'square/ic_custom',currentIndex: 101));
    spuareType.add(new SpuareTypeModel(title: '查询经销商',urlPath: 'square/ic_dealer',currentIndex: 102));
    spuareType.add(new SpuareTypeModel(title: '预约试驾',urlPath: 'square/ic_drive',currentIndex: 103));
    spuareType.add(new SpuareTypeModel(title: '金融计算器',urlPath: 'square/ic_calculator',currentIndex: 104));
    return spuareType;
  }

  Widget itemList(SpuareTypeModel spuareTypeModel){
    return Container(
      width: ScreenUtil().setWidth(750/4),
      decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
            bottom: BorderSide(color: Colors.black12, width: 0.5),
            right: BorderSide(color: Colors.black12, width: 0.5),
          )),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Image.asset(
            ImageUtils.getImgPath( spuareTypeModel.urlPath),
            width: ScreenUtil().setWidth(60.0),
            height: ScreenUtil().setHeight(60.0),
          ),
          Container(
            padding: EdgeInsets.all(5.0),
            child: Text(
              spuareTypeModel.title,
              style: TextStyle(fontSize: ScreenUtil().setSp(20.0)),
            ),
          )
        ],
      ),
    );
  }

}
